<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('承办部门')"/>
    <link th:href="@{/ajax/libs/bootstrap-switch/bootstrap-switch.min.css}" rel="stylesheet">
</head>
<style>
    label {
        font-weight: bold;
    }

    @font-face {
        font-family: 'huawen';
        src: url("/fonts/huawen.woff2");
    }
    .tltieBoder {
        height: 40px;
    }
    .smsnote {
        display: flex;
        flex-direction: row;
        justify-content: flex-start;
        margin: 2px 0px 0px 15px;
    }
</style>

<body style="background-color: #F4F6FA; font-size: 13px;font-family:'huawen' ;font-weight: bold">
<div class="main-content" style="margin: 0;padding: 0">
    <form id="form-user-add"  class="form-horizontal" style="background-color: #F4F6FA;">
        <input type="hidden" value="-1" name="callId">
        <input type="hidden" value="-1" name="tapeId">

        <div class="col-sm-12 entering-page">
            <!--    承办部门    -->
            <div class="col-sm-12 tltieBoder">
                <div class="blueBorder"></div>
                <h4 style="margin:0 0 0 10px">拟派承办部门</h4>
            </div>

            <div class="col-sm-12">
                <div class="form-group col-sm-6">
                    <label class="col-sm-4 control-label  entering-pd">工单性质：</label>
                    <div class="col-sm-8">
                        <select name="setProId" id="workCharacter" class="form-control">
                            <option value="">-请选择-</option>
                            <option value="11" selected>普通工单</option>
                            <option value="31">呈批工单</option>
                        </select>
                        <input type="hidden" name="setProName">
                    </div>
                </div>
                <div class="form-group col-sm-6">
                    <label class="col-sm-4 control-label  entering-pd">办理方式：</label>
                    <div class="col-sm-8">
                        <select name="dealCode" id="transactionWay" class="form-control"
                                required="required">
                            <option value="">-请选择-</option>
                            <option value="11" selected>研究办理</option>
                            <option value="21">酌情办理</option>
                        </select>
                        <input type="hidden" name="dealName" value="研究办理">
                    </div>
                </div>
            </div>
            <div class="col-sm-12">
                <div class="form-group col-sm-6">
                    <label class="col-sm-4 control-label is-required entering-pd">交办次序：</label>
                    <div class="col-sm-8">
                        <select name="seqCode" id="workOrder" class="form-control"
                                required="required">
                            <option value="">-请选择-</option>
                            <option value="10" selected th:selected="${seqCode==10}">初次交办</option>
                            <option value="20" th:selected="${seqCode==20}">再次交办</option>
                            <option value="30" th:selected="${seqCode==30}">三次交办</option>
                        </select>
                        <input type="hidden" value="初次交办" name="seqName" th:value="${seqName != null ? seqName : '初次交办'}">
                    </div>
                </div>
                <div class="form-group col-sm-6">
                    <label class="col-sm-4 control-label is-required entering-pd">办理性质：</label>
                    <div class="col-sm-8">
                        <select name="sortCode" class="form-control" required="required">
                            <option value="">-请选择-</option>
                            <option value="11" selected>主办</option>
                        </select>
                        <input type="hidden" name="sortName" value="主办">
                    </div>
                </div>
            </div>
            <div class="col-sm-12">
                <div class="form-group col-sm-6">
                    <label class="col-sm-4 control-label is-required entering-pd">承办单位：</label>
                    <div class="col-sm-8">
                        <input type="text" name="sbdeptName" class="form-control" id="deptShort" placeholder=""
                               autocomplete="off" th:placeholder="请选择承办部门"
                               onclick="SelectDeptAll()" required="required">
                        <input type="hidden" name="sbdeptId" id="noUnit">
                        <input type="hidden" name="zpFlag" id="zpFlag" value="0">
                    </div>
                </div>
                <div class="form-group col-sm-6">
                    <label class="col-sm-4 control-label is-required entering-pd">办理期限：</label>
                    <div class="col-sm-8">
                        <input type="text" name="backLimit" th:value="${@commonServiceImpl.getDeptBackLimit('__${deptId}__',5)}"
                               class="form-control transaction" id="transaction"
                               placeholder="请输入名称" required="required">
                        <div class="input-group-append " style="position: absolute;top: 10px;right: 25px;">
                            <span class="glyphicon glyphicon-calendar"></span>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-sm-12">
                <div class="form-group col-sm-12">
                    <label class="col-sm-2 control-label  entering-pd" style="margin-left: -5px;">办理要求：</label>
                    <div class="col-sm-10" style="width: 620px;">
                            <textarea id="sendDesc" name="sendDesc" maxlength="1000" class="form-control workRemark" rows="3"
                            >请 XXX 调查处理后直接与来话人联系，并将处理结果抄复我办。请注意来话人个人信息保密。</textarea>
                        <span>还可以输入<i class="workRemarkI">1000</i>个文字</span>
                    </div>
                </div>
            </div>
            <div class="col-sm-12">
                <div class="form-group col-sm-12">
                    <label class="col-sm-2 control-label entering-pd" style="margin-left: -5px;">派单备注：</label>
                    <div class="col-sm-10" style="width: 620px;">
                        <input name="sendRemark" type="text" class="form-control" id="remark">
                    </div>
                </div>
            </div>
            <div class="col-sm-12">
                <div class="form-group col-sm-6">
                    <label class="col-sm-4 control-label  entering-pd">派发单位：</label>
                    <div class="col-sm-8">
                        <input name="sdeptName" th:value="${sdeptName}" type="text" class="form-control"
                               id="sdeptName"
                               placeholder="请输入名称">
                        <input type="hidden" name="sdeptId" id="sdeptId" th:value="${sdeptId}">
                    </div>
                </div>
                <div class="form-group col-sm-6">
                    <label class="col-sm-4 control-label  entering-pd">派发人：</label>
                    <div class="col-sm-8">
                        <input name="suserName" th:value="${suserName}" type="text" class="form-control"
                               id="distributePerson"
                               placeholder="请输入名称">
                        <input type="hidden" name="suserNo" th:value="${suserNo}">
                    </div>
                </div>
            </div>
            <input name="deptId" id="deptId" th:value="${deptId}" type="hidden">
            <input name="fpDirect" id="fpDirect" type="hidden">
        </div>

    </form>
</div>

<script th:src="@{/ajax/libs/layui/laydate.js}"></script>
<th:block th:include="include :: footer"/>
<script th:src="@{/js/deptdiag.js}"></script>
<script th:src="@{/ajax/libs/bootstrap-switch/bootstrap-switch.min.js}"></script>
<script>
    var prefix = ctx + "gaoxin/system/sendBack";

    // let wfId = [[${wfId}]];
    // let telId = [[${telId}]];
    // var sbId = [[${sbId == null ? 0 : sbId}]];
    var lock = false;//默认未锁定
    // var deptNo = [[${session.ssnObjUser.deptId}]];
    // var pbackLimit = document.getElementById('pbackLimit').value;
    //不是锦江区
    // if(deptNo != '304040' && pbackLimit != '') {
    //     document.forms[0].backLimit.value = pbackLimit;
    // }
    //
    function submitHandler(rows) {
        let pkIds= "";
        let wfIds= "";
        if(rows.length === 0){
            return
        }else{
            $.each(rows,function(index){
                pkIds += rows[index].pkId + ",";
                wfIds += rows[index].wfId + ",";
            })
            pkIds = pkIds.substring(0,pkIds.length - 1);
            wfIds = wfIds.substring(0,wfIds.length - 1);
        }
        debugger
        if ($('#sdeptId').val() != $('#deptId').val()) {
            $('#fpDirect').val(1);
        } else {
            $('#fpDirect').val(0)
        }
        if ($.validate.form()) {
            var data = $('#form-user-add').serializeArray();
            data.push({name: "wfIds", value: wfIds});
            data.push({name: "pkIds", value: pkIds});
            if(lock) return;
            lock = true;
            var config = {
                url: '/gaoxin/system/mTelWF/cmnFile/batchSendToSon',
                type: "post",
                dataType: "json",
                data: data,
                beforeSend: function () {
                    $.modal.loading("正在处理中，请稍候...");
                    $.modal.disablePopBtn();
                },
                success: function (result) {
                    lock=false;//未锁定
                    $.operate.ajaxDiagSuccess(result,'data-id');
                    $.modal.enablePopBtn();
                    if(result.code === 0){
                        $.modal.msgSuccess(result.msg)
                        parent[parent.length-2].$.modal.close();
                    }
                }
            };
            $.ajax(config);
        }
    }

    function SelectDeptAll() {
        var config = {
            id: 'selectDeptDialog',
            title: '选择承办部门<span style="color:red;margin-left: 30px;">双击选中部门</span>',
            width: '1050',
            height: '550',
            url: ctx + 'gaoxin/system/mTelWF/cmnFile/deptAllM',
            skin: 'layui-layer-gray',
            btn: ['关闭'],
            yes: function (index, layero) {
                top.layer.close(index);
            }
        };
        $.modal.openOptions(config);
    }

    //是否开启短信通知
    $('[name="smsInform"]').bootstrapSwitch({
        onText: "是",
        offText: "否",
        onColor: "success",
        offColor: "info",
        size: "mini",
        onSwitchChange: function (event, state) {
            if (state === true) {
                $(this).val(1);
            } else {
                $(this).val(0);
            }
        }
    });

    // 刷新待签收列表
    function refreshNotSignList() {
        var navFrame = $('.NAP_iframe[data-id="/gaoxin/system/mTelWF/cmnFile/muSignNot"]', parent.document)[0];
        navFrame.contentWindow.$.table.refresh();
    }

    function SonBackSingle(idS, nameS, zpFlagS) {
        $('#deptShort').val(nameS);
        $('#noUnit').val(idS);
        if (zpFlagS !== undefined) $('zpFlag').val(zpFlagS);
        let sendDesc = $('#sendDesc').val();
        let endIndex = sendDesc.indexOf(" 调");
        let substring = sendDesc.substring(2,endIndex);
        $('#sendDesc').val(sendDesc.replace(substring,nameS));
    }

    function SonDirectSingle(sdeptNo, sdeptName, dNo, dName) {
        $('#deptShort').val(dName);
        $('#noUnit').val(dNo);
        $('#sdeptName').val(sdeptName);
        $('#sdeptId').val(sdeptNo);
    }

</script>
</body>
</html>

